package loan.calc.dto;

import loan.calc.domain.LoanDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import loan.calc.constant.dict.CurrencyDictEnum;
import loan.calc.constant.dict.LockStatusEnum;
import loan.calc.constant.dict.RepayMethodDictEnum;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class LoanDTO extends LoanDO implements Serializable {

    private List<LoanRateSegmentDTO> loanRateSegmentList;

    private List<LoanRepaySegmentDTO> loanRepaySegmentList;

    private List<LoanRepaymentScheduleDTO> repayScheduleList;

    public void setLoanId(Long loanId) {
        super.setLoanId(loanId);
        if (loanRateSegmentList != null && loanRateSegmentList.size() > 0) {
            loanRateSegmentList.forEach(i -> i.setLoanId(loanId));
        }
        if (loanRepaySegmentList != null && loanRepaySegmentList.size() > 0) {
            loanRepaySegmentList.forEach(i -> i.setLoanId(loanId));
        }
        if (repayScheduleList != null && repayScheduleList.size() > 0) {
            repayScheduleList.forEach(i -> i.setLoanId(loanId));
        }
    }
}
